package com.sali.b_design_pattern.f_responsibility_pattern.strategy.method02.handler.impl;

import com.sali.b_design_pattern.f_responsibility_pattern.strategy.method02.handler.AbstractCheckHandler;
import com.sali.b_design_pattern.f_responsibility_pattern.strategy.method02.pojo.entity.Result;
import com.sali.b_design_pattern.f_responsibility_pattern.strategy.method02.pojo.vo.ProductVO;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * 价格校验处理
 *
 * @author sali
 * @date 2025/3/16 10:07
 */
@Component
public class PriceCheckHandler extends AbstractCheckHandler {
    @Override
    public Result handle(ProductVO param) {
        System.out.println("价格校验 Handler 开始...");

        //非法价格校验
        boolean illegalPrice = param.getPrice().compareTo(BigDecimal.ZERO) <= 0;
        if (illegalPrice) {
            return Result.fail("PARAM_PRICE_ILLEGAL_ERROR");
        }
        // 其他校验逻辑...

        System.out.println("价格校验 Handler 通过...");

        // 执行下一个处理器
        return super.next(param);
    }
}
